package com.iandun.web.framework.core.http;

import lombok.Getter;
import lombok.Setter;

/**
 * 全局接口响应码
 *
 * @author :jason.liang
 * @date: 2021-05-19 17:20
 */
@Getter
@Setter
public class ResponseStatus {

    private int code;

    private String msg;

    public ResponseStatus(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    /**
     * 编码要求->此规范适用于所有的【基础结构&业务结构】工程
     *
     * <ol>
     *     <li>请求方式->客户端请求服务、服务端请求服务端</li>
     *     <li>关注点->客户端更加关注返回的 msg,服务端更加关注返回的 code</li>
     *     <li>返回给所有客户端的码,允许 code 重复但是必须 Msg 不重复</li>
     *     <li>返回给所有服务端的码,允许 msg 重复但是必须 code 不重复</li>
     * </ol>
     */
    public static final ResponseStatus OK = new ResponseStatus(2000, "请求成功");

    public static final ResponseStatus BAD_REQUEST = new ResponseStatus(4000, "客户端请求的语法错误,服务器无法理解");

    public static final ResponseStatus UNAUTHORIZED = new ResponseStatus(4001, "token无效");

    public static final ResponseStatus FORBIDDEN = new ResponseStatus(4003, "没有访问权限");

    public static final ResponseStatus NOTFOUND = new ResponseStatus(4004, "请求资源不存在");

    public static final ResponseStatus INTERNAL_SERVER_ERROR = new ResponseStatus(5000, "服务开小差啦,请稍后再试");
}
